<%@include file="startUpIncludes.jsp" %>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>
            New Action
        </title>
    <script type="text/javascript">
    $(document).ready(function(){
    	$('#newActionForm').submit(function(){
    	$(".TB").each(function(){
    		var currentValue = $(this).attr("value");
    		$(this).prev('.hidden').attr("value" ,currentValue);
    		//alert(currentValue);
          });
    });
    });
    </script>
    </head>
    <body>
    <jsp:include page="header.jsp" >
		<jsp:param value="true" name="loggedIn"/>
	</jsp:include>
    <div class="wrap">
	<div class="fitBG">
        <div class="main">
		<%@include file="basicLeftMenu.jsp" %>
            <div class="content">
				<jsp:include page="tabs.jsp" >
					<jsp:param value="leads" name="currentPage"/>
				</jsp:include>
                <div class="tab-content">
                <h3>New Action</h3>
                <form:form ccsClass="new-action-post" commandName="comonValidationTypesForm" method="post" action="/sales/s/new-action" id="newActionForm" >
                <div class="btns">
                <input type="submit" value="Save" class="form-btn"/><a  href="/sales/s/leads" class="form-btn">Cancel</a>
                </div>
                <div class="form-row">
                    <h4>Required Information</h4>
                    <div class="info"><label>Action Maker: </label><span>${userDetails.fName}</span></div>
                    <input type="hidden" name="parentId" value="${parentId}" />
                    <input type="hidden" name="typeId" value="${typeId}" />
                    <c:forEach items="${actionFields}" var="actionField">
                    <div class="input-col">
                        <label>${actionField.name}: </label>
                        <c:choose>
                        <c:when test="${actionField.render == 'textarea' }">
                        <input type="hidden" name="${fn:trim(actionField.id)}" class="hidden" />
                        <textarea class="TB"></textarea>
                        </c:when>
                        <c:when test="${actionField.render == 'text' }">
                        <input type="hidden" name="${fn:trim(actionField.id)}" class="hidden" />
                        <form:input path="${actionField.validationType}" cssClass="TB"/>
                        </c:when>
                        <c:when test="${actionField.render == 'radio' }">
                        <input type="hidden" name="${fn:trim(actionField.id)}" class="hidden" />
                            <c:forEach items="${actionField.actionColumnPredefinedValues}" var="preValue">
                           	 <form:radiobutton path="${actionField.validationType}" value="${preValue.id}" cssClass="RdCh"/>
                           	 <span class="RdCh">${preValue.value}</span>
                    		</c:forEach>
                        </c:when>
                        <c:when test="${actionField.render == 'checkbox' }">
                        <input type="hidden" name="${fn:trim(actionField.id)}" class="hidden" />
                            <c:forEach items="${actionField.actionColumnPredefinedValues}" var="preValue">
                           	 <form:checkbox path="${actionField.validationType}" value="${preValue.id}" cssClass="RdCh" />
                           	 <span class="RdCh">${preValue.value}</span>
                    		</c:forEach>
                        </c:when>
                        <c:when test="${actionField.render == 'select' }">
                        <input type="hidden" name="${fn:trim(actionField.id)}" class="hidden" />
                           <form:select cssClass="TB" path="${actionField.validationType}" multiple="false" id="${actionField.name}" >
                            <c:forEach items="${actionField.actionColumnPredefinedValues}" var="preValue">
                           	 <form:option value="${preValue.id}">${preValue.value}</form:option>
                    		</c:forEach>
                           </form:select>
                        </c:when>
                        </c:choose>
                        
                    </div>
                    </c:forEach>
                </div>
                <div class="btns">
                <input type="submit" value="Save" class="form-btn"/><a href="/sales/s/leads" class="form-btn">Cancel</a>
                </div>
                </form:form>
                </div>
            </div>
        </div>
        
    <%@include file="footer.jspf" %>
    </div>
    </div>

    </body>
</html>